<div class="nav-sub w1180">
	<ul class="zoom">
		<li><a class="on" href="">编辑溯源报告</a></li>
		<li><a href="/crm/material/catelog-list">溯源类型列表</a></li>
		<li><a href="/crm/material/cate-list">溯源类目列表</a></li>
		<li><a href="/crm/material/list">溯源列表</a></li>
		<li><a href="/crm/material/report-list">溯源报告列表</a></li>
	</ul>
</div>
<div class="main-ct w1180">
<!-- 	<a href="javascript:;" class="btn-cs btn-blue btn-fillet mt10">返 回</a> -->
<form id="commonForm" method="post" action="/crm/material/update-report">
	<div class="form-info mt20">
		<dl>
			<dt>溯源材料：</dt>
			<dd>
    			<select name="material_id" id="material_id">
					<?php if ($this->material):?>
    				<?php foreach ($this->material as $k=>$v):?>
    				
    					<?php if($this->report['material_id'] == $v['material_id']):?>
                               <option selected value="<?php echo $this->report['material_id'];?>"><?php echo $v['material_name']; ?></option>
                         <?php else:?>
                              <option value="<?php echo $v['material_id']; ?>"><?php echo $v['material_name']; ?></option>
                         <?php endif;?> 
                         
        			<?php endforeach; ?>
        			<?php else:?>
        				<option value="">请选择</option>
    				<?php endif;?>
    			</select>
			</dd>
		</dl>
		
		<dl>
			<dt>报告图片：</dt>
			<dd class="goods-list">
				<div class="goods-img goods-img-add" id="goods-thumb-image">
					<div class="g-img-ct"  id="cover">
						<img src="<?php if($this->report['image']):?><?php echo $this->report['image'];?><?php else:?>/images/ico/ico-add.png<?php endif;?>"  id="add-goods-thumb-image">
						<input type="hidden" name="image" id="product_thumb_image"  value="<?php echo $this->report['image'];?>">
					</div>
					<a href="javascript:delImg(this);" class="btn-del" id="del-goods-thumb-image" style="display:none"></a>
				</div>
			</dd>
		</dl>

	</div>
	<p class="mt30 txt-center">
		<input type="hidden" name="monitor_report_id" value="<?php echo $this->report['monitor_report_id'];?>">
		<input class="input-cs btn-fillet btn-green" type="submit" value="确定" />
	</p>
</form>
</div>
<script type="text/javascript" src="/plugins/webUpload/webuploader.js"></script>
<script type="text/javascript">
	var uploader = WebUploader.create({

		// 选完文件后，是否自动上传。
		auto: true,
		duplicate:1,
		swf:'/plugins/webUpload/Uploader.swf',
		// 文件接收服务端。
		server: '/crm/product/upload',
		// 选择文件的按钮。可选。
		// 内部根据当前运行是创建，可能是input元素，也可能是flash.
		pick: {
			id:'#cover',
			multiple:false
		},
		formData :{
			path:"/report",
		},
		method : 'post',
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,png',
			mimeTypes: 'image/*'
		}
	});
	uploader.on('uploadSuccess',function(file,response){
		//alert(file.id);
		console.log(file);
		console.log(response);
		if(response.state == 'SUCCESS'){
	 		$('#add-goods-thumb-image').attr("src",response.url);
	 		$('#product_thumb_image').val(response.url);
	 		$('#del-goods-thumb-image').show();
			
		}
	});

	
	$().ready(function() {
		$("#commonForm").validate({
			debug:true,
			rules: {
				material_id: {
					required: true,
				},
				image: {
					required: true,
				},
		
			},
    		submitHandler:function(form){ 
    	            form.submit();
    	    }   
		});

	});
	</script>